package com.yangoxix.lovegoing_admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yangoxix.lovegoing_admin.entity.StateEntity;
import com.yangoxix.lovegoing_admin.service.StateService;
import com.yangoxix.common.utils.PageUtils;
import com.yangoxix.common.utils.R;



/**
 *
 *
 * @author chenzou
 * @email 2598301006@qq.com
 * @date 2022-02-24 08:22:10
 */
@RestController
@RequestMapping("lovegoing_admin/state")
public class StateController {
    @Autowired
    private StateService stateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = stateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		StateEntity state = stateService.getById(id);

        return R.ok().put("state", state);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody StateEntity state){
		stateService.save(state);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody StateEntity state){
		stateService.updateById(state);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		stateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
